<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'HHP API',
	'defaultController'=>'Main',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		/*
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'Enter Your Password Here',
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		*/
	),

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),				
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
			     //id
			    'letter/<id:\w+>'=>'get/Letter/filterById',
			    //person
			    'letters/filter/person/<pname:([\w\s]+)>/'=>'get/Letter/filterByPerson',
                'letters/filter/person/name/alphabetical/<letter:(\w){1}>/'=>'get/Letter/filterByAlphabetical',
                'letters/filter/person/name/alphabetical/<from:(\w){1}>/<to:(\w){1}>/'=>'get/Letter/filterByAlphabeticalFromTo',
                //time
                'letters/filter/time/<time:([\d-,]+)>'=>'get/Letter/filterByTime',
                'letters/filter/time/<time:([\d-,]+)>/<count:count>/'=>'get/Letter/filterByTime',
                'letters/filter/time/<time:([\d-,]+)>/limit/<lfrom:(\d)+>/<lto:(\d)+>/'=>'get/Letter/filterByTime',    
                //time range           
                'letters/filter/time/<from:([\d-,]+)>/<to:([\d-,]+)>/'=>'get/Letter/filterByTimeFromTo',  
                'letters/filter/time/<from:([\d-,]+)>/<to:([\d-,]+)>/<count:count>'=>'get/Letter/filterByTimeFromTo',  
                'letters/filter/time/<from:([\d-,]+)>/<to:([\d-,]+)>/limit/<lfrom:(\d)+>/<lto:(\d)+>/'=>'get/Letter/filterByTimeFromTo',  
                //place
                'letters/filter/place/<place:([\w\s]+)>'=>'get/Letter/filterByPlace',
                'letters/filter/place/<place:([\w\s]+)>/<count:count>/'=>'get/Letter/filterByPlace',
                'letters/filter/place/<place:([\w\s]+)>/limit/<lfrom:(\d)+>/<lto:(\d)+>/'=>'get/Letter/filterByPlace',
                //category
                'letters/filter/category/<category:([\w\s]+)>/'=>'get/Letter/filterByCategory',
                'letters/filter/category/<category:([\w\s]+)>/<count:count>/'=>'get/Letter/filterByCategory',
                'letters/filter/category/<category:([\w\s]+)>/limit/<lfrom:(\d)+>/<lto:(\d)+>/'=>'get/Letter/filterByCategory',
                 //person
                'persons/top/'=>'get/Person/getAll',
                
                 //Untern todo 
            
                //count
                'letters/count/group_by/([\d]+)/'=>'get/Letter/countByYear',
                'letters/count/group_by/([\d]+-[\d]+)/'=>'get/Letter/countByMonth',
                'letters/count/group_by/month/filter/time/([\d-]+)/([\d-]+)/'=>'get/Letter/countByMonthFromTo',
                'letters/count/group_by/([\d]+-[\d]+-[d]+)/'=>'get/Letter/countByDay',
                'letters/count/group_by/day/filter/time/([\d-]+)/([\d-]+)/'=>'get/Letter/countByDayFromTo',
              
                'persons/top/filter/time/([\d-]+)/([\d-]+)/'=>'get/Person/filterByTimeFromTo',
                'persons/filter/location/(\w+)/'=>'get/Person/filterByLocation', 
                'persons/search/(.*)/'=>'get/Person/searchByName', 
                //location
                'locations/top/'=>'get/Location/getAll',
                'locations/top/filter/time/([d-]+)/'=>'get/Location/filterByTime',
                'locations/filter/location/(w+)/'=>'get/Location/filterByLocation', 
                'locations/search/(.*)/'=>'get/Location/searchByName', 
                //'(.*)/'=>'Empty/returnNull'//其他所有不匹配的都返回null
        		),
		),
		
		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=hhp_2014_tmp',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',//'hFv37jKs3
			'charset' => 'utf8',
		),
		
		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
);